
<%@page import="Domain.Website"%>
<jsp:useBean id="post" scope="page" class="Domain.PostBean" />
<jsp:setProperty name="post" property="*"/>

<jsp:useBean id="currentUser" scope="session" class="Domain.UserBean" />

<% 
    Boolean loggedIn = false;
    if(currentUser.validatePassword()) {
        loggedIn = true;
	}
	else{
		response.sendRedirect("blogview.jsp");
	}
%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Add a new post!</title>
    </head>
    <body>
        <form method="POST" action="createnewpost.jsp">
			Rubrik: <br/>
			<input type="text" name="header" />
			Text: <br/>
			<textarea name="text" rows="30" cols="60"></textarea> <br/>
			<input type="Submit" value="Post!" />
		</form>
		<%
			if(post.getHeader() != null && post.getText() != null){
				Website website = Website.getInstance();
				website.addNewPost(currentUser.getuserId(), post);
				response.sendRedirect("blogview.jsp");
			}
		%>
    </body>
</html>
